import { Cache } from "../../../cache/Cache";
import { GameMapUtil } from "../../../scene/map/GameMapUtil";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { Language } from "../../../../../extend/language/Language";
import { GameProxy } from "../../../mvc/GameProxy";
type int = number;
//class CrossGuildWarEnterWaittingRoomTips
    
    export  class CrossGuildWarEnterWaittingRoomTips
    {
        

        public startWork(arg1: int): void
        {
            if (arg1 < 2) 
            {
                return;
            }
            this._leftSeconds = arg1;
            this.isWorking = true;
            if (this._timer == null) 
            {
                this._timer = new Object /* flash.utils.Timer */(1000, this._leftSeconds);
            }
            this._timer.start();
            this._timer.addEventListener(flash.events.TimerEvent.TIMER, this.enterFrameHandler);
            return;
        }

        /* internal  */enterFrameHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            var loc1;
            var loc2=((loc1 = this)._passSeconds + 1);
            loc1._passSeconds = loc2;
            if (this._passSeconds > this._leftSeconds) 
            {
                this.dispose();
                return;
            }
            if (!this._is1MinutesTips && this._leftSeconds - this._passSeconds < 60 * 5) 
            {
                this._is1MinutesTips = true;
                this._is5MinutesTips = true;
                this.showAlert();
                this.dispose();
                return;
            }
            if (!this._is5MinutesTips && this._leftSeconds - this._passSeconds < 60 * 5) 
            {
                this._is5MinutesTips = true;
                this.showAlert();
            }
            return;
        }

        /* internal  */showAlert(): void
        {
            if (Cache.instance.guild.myGuildInfo == null) 
            {
                return;
            }
            if (GameMapUtil.curMapState.isCrossGuildWar || GameMapUtil.curMapState.isCrossGuildWarWaittingRoom) 
            {
                return;
            }
            if (!Cache.instance.crossGuildWar.hasSignUp(Cache.instance.role.entityInfo.name)) 
            {
                return;
            }
            Alert.buttonWidth = 65;
            Alert.okLabel = Language.getString(80575);
            Alert.calcelLabel = Language.getString(80576);
            Alert.show(Language.getString(80574), null, Alert.OK | Alert.CANCEL, null, this.enterConfirm);
            return;
        }

        /* internal  */enterConfirm(arg1: int): void
        {
            if (arg1 != Alert.OK) 
            {
                return;
            }
            GameProxy.copy.crossGuildWarEnterCopy();
            return;
        }

        public dispose(): void
        {
            if (this._timer != null) 
            {
                this._timer.removeEventListener(flash.events.TimerEvent.TIMER, this.enterFrameHandler);
                this._timer.stop();
                this._timer = null;
            }
            this._is1MinutesTips = false;
            this._is5MinutesTips = false;
            this.isWorking = false;
            return;
        }

        /* internal */ /* var */_is5MinutesTips: Boolean=false;

        /* internal */ /* var */_is1MinutesTips: Boolean=false;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_leftSeconds: int;

        /* internal */ /* var */_passSeconds: int=0;

        public /* var */isWorking: Boolean=false;
    }
